package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 工单
 * </p>
 *
 * @author linan
 * @date 2023-04-25
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "WorkOrderWorkOrderTypeEnum", description = "工单类型 #{SERVICE:服务工单;REPAIR:报修工单;CHECK:验收工单;WORK_OVERTIME:加班工单-枚举")
public enum WorkOrderWorkOrderTypeEnum implements BaseEnum {

    /**
     * SERVICE="服务工单"
     */
    SERVICE("服务工单"),
    /**
     * REPAIR="报修工单"
     */
    REPAIR("报修工单"),
    /**
     * CHECK="验收工单"
     */
    CHECK("验收工单"),
    /**
     * WORK_OVERTIME="加班工单"
     */
    WORK_OVERTIME("加班工单"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static WorkOrderWorkOrderTypeEnum match(String val, WorkOrderWorkOrderTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WorkOrderWorkOrderTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(WorkOrderWorkOrderTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "SERVICE,REPAIR,CHECK,WORK_OVERTIME", example = "SERVICE")
    public String getCode() {
        return this.name();
    }

}
